package model

import (
	"gorm.io/gorm"
	"time"
)

type Article struct {
	Id        uint32         `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;"  form:"id" json:"id"`
	Title     string         `gorm:"column:title;type:varchar(30);comment:标题;not null;"  form:"title" json:"title"`             // 标题
	Image     string         `gorm:"column:image;type:varchar(500);comment:封面;not null;"  form:"image" json:"image"`            // 封面
	Context   string         `gorm:"column:context;type:varchar(240);comment:内容;not null;"  form:"context" json:"context"`      // 内容
	UserId    int32          `gorm:"column:user_id;type:int;comment:发布人id;not null;"  form:"user_id" json:"user_id"`            // 发布人id
	LikeNum   int32          `gorm:"column:like_num;type:int;comment:点赞量;not null;default:0;"  form:"like_num" json:"like_num"` // 点赞量
	Collect   int32          `gorm:"column:collect;type:int;comment:收藏数;not null;default:0;"  form:"collect" json:"collect"`    // 收藏数
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);"  form:"created_at" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);"  form:"updated_at" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;"  form:"deleted_at" json:"deleted_at"`
}

func (a Article) TableName() string {
	return "article"
}
